package org.exez.modules.visitor.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.Update;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.models.auth.In;
import org.exez.modules.system.entity.SysUser;
import org.exez.modules.system.service.ISysUserService;
import org.exez.modules.visitor.entity.Institution;
import org.exez.modules.visitor.entity.VisitorAccessre;
import org.exez.modules.visitor.mapper.InstitutionMapper;
import org.exez.modules.visitor.service.IInstitutionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * @Description: 事业单位表
 * @Author: exez-boot
 * @Date:   2020-06-04
 * @Version: V1.0
 */
@Service
public class InstitutionServiceImpl extends ServiceImpl<InstitutionMapper, Institution> implements IInstitutionService {

    @Autowired
    ISysUserService iSysUserService;

    @Override
    public Institution getInstitutionByCode(String code) {
        LambdaQueryWrapper<Institution> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Institution :: getCode,code);
        queryWrapper.eq(Institution :: getDeleted,1);
        return baseMapper.selectOne(queryWrapper);
    }

    @Override
    public IPage<Institution> listInstitution(Page<Institution> page, LambdaQueryWrapper<Institution> queryWrapper) {
        IPage<Institution> pageList = this.page(page, queryWrapper);
        return pageList;
    }

    @Override
    public void saveUserQx(String userId, String institutionList) {
    //修改值
        SysUser byId = iSysUserService.getById(userId);
        byId.setInstitutionId(institutionList);
        iSysUserService.updateById(byId);
    }




}
